#include<iostream>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h> //open

int main()
{
    umask(0);
    int ret = mkfifo("common" ,0664 );
    
    int fd = open("common",O_APPEND|O_RDONLY);

    char buffer[256];
    while(1)
    {
        int n = read(fd,buffer,sizeof(buffer));
        if(n == 0)
        {
            std::cout << "消息接收停止" << std::endl;
            break;
        }
        buffer[n] = '\0';
        std::cout << buffer << std::endl;
    }
    return 0;
}